import defData from './GuaranteeDefaultData'
import {createMap, redrawMap, updateMap,ShowHideBusLayer} from './GuaranteeLLMap'

import sosOrgService from '@/services/SosOrgService'

export default {
  name: 'Guarantee',
  computed: {
    width: function () {
      return document.body.clientWidth * 0.8
    },
    height: function () {
      return document.body.clientHeight * 0.6
    }
  },
  data: () => defData,
  mounted: function () {
    this.getMap()
    this.getSosOrg()
  },
  created () {
  },
  methods: {
    getMap () {
      createMap.call(this, this)
    },
    close () {
      /*
      if (this.fullscreen == true) {
        this.fullscreen = false
        if (window.screen.width < 1280) {
          this.wwdith = '98%'
        } else {
          this.wwdith = '86%'
        }
      }
      */
    },
    reDraw () {
      redrawMap.call(this, this)
    },
    updateData () {
      updateMap.call(this, this)
    },
    goBack () {
      this.$router.push('/map')
    },
    showNo(){
      if(this.showDiv==true){
        this.showDiv=false
      }else{
        this.showDiv=true
      }
    },
    changeCheck10(val){  //搜救机构
      //this.showDiv=false;
      let e={};
      e.bustype="SosOrganization";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck1(val){ //专业救助船舶
      let e={};
      e.bustype="SosShipPro";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck2(val){  //社会力量救助船舶
      let e={};
      e.bustype="SosShipSoc";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck3(val){  //救助飞行器
      //this.showDiv=false;
      let e={};
      e.bustype="SosFlyDevice";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck4(val){  //溢油应急船舶
      //this.showDiv=false;
      let e={};
      e.bustype="EmmerShip";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck5(val){ //溢油应急库
      //this.showDiv=false;
      let e={};
      e.bustype="EmWarehouse";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck12(val) { //执法机构
      //老系统也无实现代码
    },
    changeCheck6(val){ //执法人员
      //this.showDiv=false;
      let e={};
      e.bustype="SysUser";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck8(val){ //VTS分中心
      //this.showDiv=false;
      let e={};
      e.bustype="VtsSubCenter";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck13(val){ //VTS雷达站
      //this.showDiv=false;
      let e={};
      e.bustype="VtsRadarSt";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck9(val){ //CCTV
      //this.showDiv=false;
      let e={};
      e.bustype="CctvSite";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck7(val) { //执法船艇
      //this.showDiv=false;
      let e={};
      e.bustype="Zfct";
      e.show=val;
      ShowHideBusLayer.call(e,e);
    },
    changeCheck11(val) { //执法车辆
      //老系统就没实现
    },
    scheck(val){   //列表信息
      if (val=="专业救助船舶"){
        this.$router.push('/listSosShipPro');
      }else if (val=="社会力量救助船舶"){
        this.$router.push('/listSosShipSoc');
      }else if (val=="溢油应急船舶"){
        this.$router.push('/listEmmerShip');
      }else if (val=="救助飞行器"){
        this.$router.push('/listSosFlydev');
      }else if (val=="溢油应急库"){
        this.$router.push('/listEmWarehouse');
      }else if (val=="VTS分中心"){
        this.$router.push('/listVtsSubCenter');
      }else if (val=="VTS雷达站"){
        this.$router.push('/listVtsRadarSt');
      }else if (val=="CCTV"){
        this.$router.push('/listCctv');
      }
    },
    getSosOrg(){ //获取搜救结构
      this.sosOrgid='';
      this.sosOrg=[];
      sosOrgService.searchAll().then(list => {
          for (let k=0;k<list.length;k++){
            if (list[k].level==1){
              this.sosOrg.push(list[k]);
            }
          }
      });
    },
    changeSosOrg(val) { //搜救机构下拉框改变
      //this.showDiv=false
      sessionStorage.setItem('guaranteeSosorgid',this.sosOrgid);
      if (this.sosOrgid!=''){
        //老系统是有逻辑代码，也就是显示次搜救机构的下级搜救机构，不包括下下级
        this.$router.push({path:'/sosOrgTree',query:{id:this.sosOrgid}});
      }
    },
    //路由跳转相关
    proRouter () {
      this.$router.push('/produce')
    },
    enRouter () {
      this.$router.push('/supervise')
    },
    supRouter () {
      this.$router.push('/ensure')
    }
  }
}
